<?php

namespace App\Models\Finance;

use Illuminate\Database\Eloquent\Model;

/**
 * 薪资计算字段数据模型
 *
 * Date: 2018/5/28
 * @author George
 * @property int $id
 * @property int $company_id
 * @property int $pattern_id
 * @property string $name
 * @property bool $salary
 * @property bool $tax
 * @package App\Models\Finance
 */
class Field extends Model
{
	/**
	 * 定义可批量填充字段
	 *
	 * @var array
	 * Date: 19/03/2018
	 * @author George
	 */
	protected $guarded = ['id'];

	/**
	 * 定义属性数据类型
	 *
	 * @var array
	 * Date: 2018/6/5
	 * @author George
	 */
	protected $casts = [
		'pattern_id' => 'int',
		'value' => 'int',
		'salary' => 'boolean',
		'tax' => 'boolean'
	];

	/**
	 * 获取字段的规则
	 *
	 * Date: 2018/6/13
	 * @author George
	 * @return \Illuminate\Database\Eloquent\Relations\HasOne
	 */
	public function regulation()
	{
		return $this->hasOne(Regulation::class, 'field_id', 'id');
	}
}
